import {ref} from 'vue'
import { defineStore } from 'pinia'
import * as fileApi from '@/api/fileApi'
import {ElMessage} from "element-plus";

export const usePreviewTextStore = defineStore('previewTextStore', () => {

  const show = ref(false)
  const title = ref('')
  const value = ref(null)
  const absolutePath = ref(null)
  async function text() {
    let res = await fileApi.text(absolutePath.value)
    value.value = res.data
    show.value = true
  }

  async function init() {
    await text()
  }

  function clear() {
    value.value = null
  }

  return {show,text,title,value,clear,absolutePath,init}

})
